//
//  TabBarViewController.m
//  TabBar
//
//  Created by 温人米 on 2019/1/9.
//  Copyright © 2019年 温人米. All rights reserved.
//

#import "TabBarViewController.h"
#import "OneViewController.h"
#import "TwoViewController.h"
#import "ThressViewController.h"
#import "FourViewController.h"
#import "FiveViewController.h"
#import "TabBar.h"
#import "TabBarView.h"

#import "RMNavigationViewController.h"

@interface TabBarViewController ()<TabBarViewDelegate>

@property (nonatomic, strong)TabBar *rm_tabBar;

@end

@implementation TabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor grayColor];
    
    TabBar *tabBar = [[TabBar alloc] init];
    tabBar.tabBarView.viewDelegate = self;
    [self setValue:tabBar forKey:@"tabBar"];
    
    RMNavigationViewController *nav1 = [[RMNavigationViewController alloc] initWithRootViewController:[OneViewController new]];
    [self addChildViewController:nav1];

    RMNavigationViewController *nav2 = [[RMNavigationViewController alloc] initWithRootViewController:[TwoViewController new]];
    [self addChildViewController:nav2];

    RMNavigationViewController *nav3 = [[RMNavigationViewController alloc] initWithRootViewController:[ThressViewController new]];
    [self addChildViewController:nav3];

    RMNavigationViewController *nav4 = [[RMNavigationViewController alloc] initWithRootViewController:[FourViewController new]];
    [self addChildViewController:nav4];

    RMNavigationViewController *nav5 = [[RMNavigationViewController alloc] initWithRootViewController:[FiveViewController new]];
    [self addChildViewController:nav5];
    
    //self.viewControllers = @[nav1,nav2];
}

-(void)TabBarView:(TabBarView *)view didSelectItemAtIndex:(NSInteger)index{
    self.selectedIndex = index;
}

-(void)TabBarViewDidClickCenterItem:(TabBarView *)view{
    
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"点击了中间的按钮" message:@"" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [alertController dismissViewControllerAnimated:YES completion:nil];
    }];
    [alertController addAction:action];
    [self presentViewController:alertController animated:YES completion:nil];
}


@end
